﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.EntityModel.Prototype;
using YasharEl.Infrastructure.PersistenceModel.NHibernate.UserTypes;
using YasharEl.Infrastructure.Core.Prototype;

namespace YasharEl.Infrastructure.Core.PersistenceModel.NHibernate.Prototype.Mappings
{
    public class PropertyDefinitionEntityMap : ClassMap<PropertyDefinitionEntity>
    {
        public PropertyDefinitionEntityMap()
        {
            Table("PropertyDefinitions");
            ReadOnly();
            Cache.ReadOnly();

            Id(e => e.PropertyDefinitionId)
                .Column("PropertyDefinitionId")
                .GeneratedBy.Assigned();

            Map(e => e.Key)
                .Column("PropertyKey")
                .Not.Nullable()
                .Unique()
                .Length(255);

            Map(e => e.Name)
                .Column("PropertyName")
                .Not.Nullable()
                .Length(255);

            Map(e => e.Description)
                .Column("PropertyDescription")
                .Length(1000)
                .Not.Nullable();

            Map(e => e.DisplayName)
                .Column("PropertyDisplayName")
                .Not.Nullable()
                .Length(255);

            Map(e => e.DataType)
               .Column("DataType")
               .Not.Nullable()
               .CustomType<EnumerationType<DataType>>();
        }
    }
}
